/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.barco.ledApi;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Huyu
 */
public class HttpBase {

    public HttpBase() {

    }

    public String RequestUrl(String UrlStr) {
        String responseStr = "";
        String sCurrentLine = null;
        try {
            URL url = new URL(UrlStr);
            URLConnection Urlconnection = url.openConnection();
            HttpURLConnection httpConnection = (HttpURLConnection) Urlconnection;
            httpConnection.setConnectTimeout(LedConfig.m_ConnectTimeout);
            httpConnection.setReadTimeout(LedConfig.m_ReadTimeout);

            httpConnection.setRequestMethod("GET");
            InputStream urlStream = httpConnection.getInputStream();
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlStream));

            while ((sCurrentLine = bufferedReader.readLine()) != null) {
                responseStr += sCurrentLine;
            }
        } catch (Exception ex) {
             //System.out.println("ex " + ex.getMessage());
        }

        return responseStr;
    }
}
